﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using HandyControl.Data;

namespace Sensor.UI.Converters;

public class BoolToHCBadgeStatus : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return ToValue(value);
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return ToValue(value);
    }

    private static BadgeStatus ToValue(object value)
    {
        if (value != null && bool.TryParse(value.ToString(), out bool result))
        {
            return result ? BadgeStatus.Processing : BadgeStatus.Dot;
        }
        return BadgeStatus.Dot;
    }
}
